<?php
if (!defined("__WD__")) exit("Wrong Connect");


class __KongLoad extends __Load {
	
	function __construct() {
		parent::__construct();
	}
	function model( $name, &$ret = null ) {
		return parent::model($name, $ret);
	}
	function module( $name, &$ret = null ) {
		return parent::module($name, $ret);
	}
	function helper( $name ) {
		return parent::helper($name);
	}
	
	function kong( $name, $data = array() ) {
		$url = __ROOT__."/kong/".$this->data->kong->id."/".$name.".php";
		if ( !file_exists( $url) ) throw new Exception("view파일의 위치가 잘못 지정되어있습니다. (Path : {$url})");
		
		extract( get_object_vars( $this->data ) );
		if (is_array($data)) extract( $data );
		
		include $url;
		
		return true;
	}
	
}
class __Kong {

	protected $id = null;

	function __construct() {

		$this->load = &getInstance( '__KongLoad' );
		$this->data = &getInstance( '__Data' );

		$this->data->make("kong");
		
		$this->data->kong->path	= $this->data->config->kong['path'];
		$this->data->kong->id	= $this->data->config->kong['id'];
		$this->data->kong->name	= $this->data->config->kong['name'];
				
		$this->data->kong->library	= "http://".HOME."/kong/".$this->data->kong->id;
		$this->data->kong->href		= $this->data->href."/".$this->data->kong->id;
	}

	function _header() {
		$this->load->view("admin/header");
	}
	function _footer() {
		$this->load->view("admin/footer");
	}
	function css( $name ) {

		if ( !isset($this->data->head) ) $this->data->head = "";

		$library = $this->data->kong_library;
		$this->data->head .= <<<EOD
<link rel="stylesheet" href="{$library}/{$name}.css" />

EOD;
		
	}
	function js( $name ) {

		if ( !isset($this->data->body) ) $this->data->body = "";

		$library = $this->data->kong_library;
		$this->data->body .= <<<EOD
<script src="{$library}/{$name}.js"></script>

EOD;
		
	}
}
